<script lang="ts" setup>
import { get, post, message, loadFile } from '@/utils'
import { FormInstance } from '@arco-design/web-vue'
const props = defineProps<{
  show: boolean
  id: any
}>()
const emit = defineEmits(['update:show', 'reset', 'confirm'])
const formRef = ref() as Ref<FormInstance>
const detail = reactive({
  remark: '',
  status: '' as any,
  ids: props.id,
  remitType: 1,
})
const submit = done => {
  formRef.value.validate(err => {
    if (!err) {
      const query = Object.assign({}, detail)
      post(
        {
          url: '/server-user/admin/withdraw/audit',
          data: query,
        },
        ({ code, msg }) => {
          message({
            type: code == 200 ? 'success' : 'error',
            content: msg,
          })
          emit('update:show', false)
          emit('confirm')
          done(true)
        },
        () => done(false)
      )
    } else done(false)
  })
}
</script>
<template>
  <CModal v-model:visible="props.show" @before-ok="submit" :mask-closable="false" :title="props.id ? '编辑' : '新建'" @cancel="emit('update:show', false)">
    <div class="content">
      <a-form :model="detail" ref="formRef" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 16 }">
        <a-form-item label="打款方式" field="remitType" :rules="[{ required: true, message: '请选择打款方式' }]" :validate-trigger="['change', 'blur']">
          <a-radio-group type="button" v-model="detail.remitType">
            <a-radio :value="1">线下</a-radio>
            <a-radio :value="2">线上</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item label="审核结果" field="status" :rules="[{ required: true, message: '请选择审核结果' }]" :validate-trigger="['change', 'blur']">
          <a-radio-group type="button" v-model="detail.status">
            <a-radio :value="1">审核通过</a-radio>
            <a-radio :value="-1">审核拒绝</a-radio>
          </a-radio-group>
        </a-form-item>

        <a-form-item label="审核拒绝原因" v-if="detail.status == -1" field="remark" :rules="[{ required: true, message: '请输入审核拒绝原因' }]" :validate-trigger="['change', 'blur']">
          <a-textarea v-model="detail.remark" placeholder="请输入" />
        </a-form-item>
      </a-form>
    </div>
  </CModal>
</template>
<style lang="less" scoped></style>
